//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
#include <stdarg.h>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
struct SSearchNode
{
    SSearchNode * Pre;
    SSearchNode * Next;
    TStrings * FileList;
    TStrings * DirList;
    int Index;
    bool SyncFlag;
    AnsiString Path;

    __fastcall SSearchNode()
        :Pre(NULL),Next(NULL),FileList(NULL),DirList(NULL),Index(0),SyncFlag(false)
    {
        FileList = new TStringList();
        DirList = new TStringList();
    }
    __fastcall ~SSearchNode()
    {
        if( FileList != NULL )
        {
            delete FileList;
            FileList = NULL;
        }
        if( DirList != NULL )
        {
            delete DirList;
            DirList = NULL;
        }
    }
    bool FindAtFile(const AnsiString & paramFile);
    bool FindAtDir(const AnsiString & paramDir);
};
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TLabel *Label1;
        TLabel *Label2;
        TEdit *Edit1;
        TEdit *Edit2;
        TButton *Button1;
        TButton *Button2;
        TButton *Button3;
        TButton *Button4;
        TButton *Button5;
        TButton *Button6;
        TOpenDialog *OpenDialog1;
        TSaveDialog *SaveDialog1;
    TMemo *Memo1;
    TTimer *Timer1;
    TLabel *Label3;
    TEdit *Edit3;
    TLabel *Label4;
        void __fastcall Button5Click(TObject *Sender);
    void __fastcall Button6Click(TObject *Sender);
    void __fastcall Button3Click(TObject *Sender);
    void __fastcall Button4Click(TObject *Sender);
    void __fastcall Button1Click(TObject *Sender);
    void __fastcall Timer1Timer(TObject *Sender);
    void __fastcall Button2Click(TObject *Sender);
private:	// User declarations
    void Info(const char * fmt,...);
    AnsiString & __fastcall GetSearchPath(AnsiString & paramPath);
    int __fastcall ForceRemoveDir(const AnsiString & parmaDir);
    int __fastcall ForceMakeDir(const AnsiString & paramDir);
    bool __fastcall FindFileToNode(const AnsiString & paramPath,SSearchNode * paramNode);
    void Sync(const AnsiString & paramSPath, SSearchNode * paramS,const AnsiString & paramDPath, SSearchNode * paramD);
    void RemoveNotSrc(SSearchNode * paramS,SSearchNode * paramD);
private:
    SSearchNode m_S;
    SSearchNode m_D;
    int m_TimeOffset;
    bool m_StartMonitor;
    bool m_UpdateFlag;
    DWORD m_LastTime;
public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
